﻿using Md.Api.Model.Manage.SysDictType.Request;
using Md.Dapper.Repositories.Md;

namespace Md.Api.Service.Manage.SysDictType;
/// <summary>
/// 通过字典编号删除系统字典类型服务
/// </summary>
public class DeleteSysDictTypeByDictIdService : ApiBase<RequestDeleteSysDictTypeByDictIdModel>
{
    /// <summary>
    /// 系统字典类型仓储
    /// </summary>
    public SysDictTypeRep sysDictTypeRep { get; set; }
    /// <summary>
    /// 执行
    /// </summary>
    protected override void ExecuteMethod()
    {
        var ids = Parameter.DictIds.Split(",");

        if (ids.Length == 0)
        {
            throw new AggregateException("字典编号不能为空");
        }

        int res = 0;

        foreach (var id in ids)
        {
            var delRes = sysDictTypeRep.DeleteSysDictTypeByDictId(Convert.ToInt64(id));

            res += delRes;
        }

        Result.Data = res;
    }
}
